<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var p = {
      id: 1001,
      _age: 10,
    }

    console.log(p);
    Object.defineProperties(p, {
      name: {
        configurable: true,
        enumerable: false,
        value: '张三',
        writable: true
      },
      sex: {
        configurable: false,
        enumerable: false,
        value: '男',
        // writable: false
      },
      age: {
        get: function () {
          return this._age;
        },
        set: function (val) {
          this._age = val;
        }
      }
    })

    p.sex = "女"
    p.age = 20
    console.log(p);



  </script>
</body>

</html>